home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2005 March
/
Gamestar_71_2005-03_dvd.iso
/
Dema
/
willofsteel_demo.exe
/
{app}
/
Data
/
Shaders
/
default14sf.fx
< prev
next >
Wrap
Text File
|
2004-10-23
|
15KB
|
558 lines
float4x4 WorldViewProjection;
float4x4 ShadowViewProjection;
float4x4 TextureMatrix;
float4x4 WorldMatrix;
float4x4 ViewIT;
texture AlphaTexture;
texture DiffuseTexture;
texture ShadowTexture;
texture CloudsTexture;
texture FogOfWar;
texture BurnedTexture;
float4 BurnFactor = { 0.4, 0.4, 0.4, 0.4 };
float3 LightDirection = { 0.0f, 0.0f, 0.0f };
float3 SunColor = { 1., 0.86, .70 };
float3 Ambient = { 0.24, 0.12, 0.04 };
float4 FogScale = { 0.001953125, 0.001953125, 0.001953125, 0.001953125 };
float4 ZBias = { 0.0, 0.0, 0.0, -0.004 };
float4 ShadowOffset;
float4 CloudUVShift = { 0.0, 0.0, 0.0, 0.0 };
float4 CloudScale = { 0.01, 0.01, 0.01, 0.01 };
float4 BlinkFactor = { 0.0, 0.0, 0.0, 0.0 };
technique Technique0
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
Texture[1] = (ShadowTexture);
Texture[2] = (FogOfWar);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[4] = <ShadowViewProjection>;
VertexShaderConstant[8] = <TextureMatrix>;
VertexShaderConstant[12] = <WorldMatrix>;
VertexShaderConstant[26] = <BlinkFactor>;
VertexShaderConstant[27] = <FogScale>;
VertexShaderConstant[30] = <LightDirection>;
VertexShaderConstant[31] = <ZBias>;
VertexShaderConstant[32] = <SunColor>;
ALPHABLENDENABLE = FALSE;
ALPHATESTENABLE = FALSE;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c29 - Cloud UV shift
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v6
m4x4 oPos, v0, c0 // Transform and output position
m4x4 r0, v0, c12 // Transform and output position
mul r0, r0, c27
mov oT2.x, r0.x // Fog of war texture coords
mov oT2.y, r0.z // Fog of war texture coords
mov oT0, v6 // Copy texture coords
dp4 oT1.x, v0, c8 // Shadow map projection
dp4 oT1.y, v0, c9
dp3 r0, -v3, c30 // Diffuse //Lighting
mul r0, r0, c32
add oD0, r0, c26
dp4 r0, v0, c6 // Depth in light space
add oT3.x, r0, c31.w // Add Bias
};
PixelShaderConstant[17] = <Ambient>;
PixelShader =
asm
{
ps_1_4
def c0, 1, 1, 1, 1
def c1, 0.0, 0.0, 0.0, 0
dcl t0.xyzw
dcl t1.xy
dcl t2.xy
dcl t3.x
dcl v0.rgba
dcl_2d s0
dcl_2d s1
dcl_2d s2
texld r10, t1, s1 // Z - semplovani Z projektovane teksture
sub r9.r, r10.r, t3.x // razlika Z vrednosti
mov r1, c1 // r1 - 1, 1, 1, 1
cmp r10, r9.r, c0, r1 //-r9.r//, r1
//mov r0, t0
frc r0, t0
texld r1, r0, s0
mad r0, r10, v0, c17 // (shadow * diffuse) + ambient
mul r0, r1, r0
texld r2, t2, s2
mul r0, r2, r0
mov oC0, r0 // output
};
}
}
// rendering u shadow mapu
technique Technique1
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[31] = <ZBias>;
ALPHABLENDENABLE = FALSE;
ALPHATESTENABLE = FALSE;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_texcoord0 v6
m4x4 r0, v0, c0 // Transform position
mov oPos, r0 // Output position
mov oT0, v6
mov oT1.x, r0.z // Output depth
};
PixelShader =
asm
{
ps_1_4
dcl t0.xyzw
dcl t1.x
dcl_2d s0
mov r0, t1.x
mov oC0, r0
};
}
}
technique Technique2
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
Texture[1] = (ShadowTexture);
Texture[2] = (FogOfWar);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[4] = <ShadowViewProjection>;
VertexShaderConstant[8] = <TextureMatrix>;
VertexShaderConstant[12] = <WorldMatrix>;
VertexShaderConstant[26] = <BlinkFactor>;
VertexShaderConstant[27] = <FogScale>;
VertexShaderConstant[30] = <LightDirection>;
VertexShaderConstant[31] = <ZBias>;
VertexShaderConstant[32] = <SunColor>;
ALPHABLENDENABLE = TRUE;
SRCBLEND = SRCALPHA;
DESTBLEND = INVSRCALPHA;
ALPHATESTENABLE = TRUE;
ALPHAFUNC = GREATER;
ALPHAREF = 1;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v6
m4x4 oPos, v0, c0 // Transform and output position
m4x4 r0, v0, c12 // Transform and output position
mul r0, r0, c27
mov oT2.x, r0.x // Fog of war texture coords
mov oT2.y, r0.z // Fog of war texture coords
mov oT0, v6 // Copy texture coords
dp4 oT1.x, v0, c8 // Shadow map projection
dp4 oT1.y, v0, c9
dp3 r0, -v3, c30 // Diffuse //Lighting
mul r0, r0, c32
add oD0, r0, c26
dp4 r0, v0, c6 // Depth in light space
add oT3.x, r0, c31.w // Add Bias
};
PixelShaderConstant[17] = <Ambient>;
PixelShader =
asm
{
ps_1_4
def c0, 1, 1, 1, 1
def c1, 0.0, 0.0, 0.0, 0
def c2, 0., 0., 0., .0 // zero
def c3, 1.0, 1.0, 1.0, 1.0 // fog color
def c18, 10., 0., 0.1, 1.0 // ambient color
dcl t0.xyzw
dcl t1.xy
dcl t2.xy
dcl t3.x
dcl v0.rgba
dcl_2d s0
dcl_2d s1
dcl_2d s2
texld r10, t1, s1 // Z - semplovani Z projektovane teksture
sub r9.r, r10.r, t3.x // razlika Z vrednosti
mov r1, c1 // r1 - 1, 1, 1, 1
cmp r10, r9.r, c0, r1 //-r9.r//, r1
//mov r0, t0
frc r0, t0
texld r1, r0, s0
mad r0, r10, v0, c17 // (shadow * diffuse) + ambient
mul r0, r1, r0
texld r2, t2, s2
mul r0, r2, r0
mov r0.a, r1.a
mov oC0, r0 // output
};
}
}
// rendering u shadow mapu
technique Technique3
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[31] = <ZBias>;
ALPHABLENDENABLE = FALSE;
ALPHATESTENABLE = FALSE;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_texcoord0 v6
m4x4 r0, v0, c0 // Transform position
mov oPos, r0 // Output position
mov oT0, v6
mov oT1.x, r0.z // Output depth
};
PixelShader =
asm
{
ps_1_4
def c0, 0.5, 1, 1, 1
dcl t0.xyzw
dcl t1.x
dcl_2d s0
texld r1, t0, s0
sub r0, r1.w, c0.x // simulate alpha test
texkill r0
mov r0, t1.x
mov oC0, r0
};
}
}
technique Technique4
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
Texture[1] = (ShadowTexture);
Texture[2] = (FogOfWar);
Texture[3] = (BurnedTexture);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[4] = <ShadowViewProjection>;
VertexShaderConstant[8] = <TextureMatrix>;
VertexShaderConstant[12] = <WorldMatrix>;
VertexShaderConstant[26] = <BlinkFactor>;
VertexShaderConstant[27] = <FogScale>;
VertexShaderConstant[30] = <LightDirection>;
VertexShaderConstant[31] = <ZBias>;
VertexShaderConstant[32] = <SunColor>;
ALPHABLENDENABLE = TRUE;
SRCBLEND = SRCALPHA;
DESTBLEND = INVSRCALPHA;
ALPHATESTENABLE = TRUE;
ALPHAFUNC = GREATER;
ALPHAREF = 1;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v6
m4x4 oPos, v0, c0 // Transform and output position
m4x4 r0, v0, c12 // Transform and output position
mul r0, r0, c27
mov oT2.x, r0.x // Fog of war texture coords
mov oT2.y, r0.z // Fog of war texture coords
mov oT0, v6 // Copy texture coords
mov oT4, v6 // Copy texture coords
dp4 oT1.x, v0, c8 // Shadow map projection
dp4 oT1.y, v0, c9
dp3 r0, -v3, c30 // Diffuse //Lighting
mul r0, r0, c32
add oD0, r0, c26
dp4 r0, v0, c6 // Depth in light space
add oT3.x, r0, c31.w // Add Bias
};
PixelShaderConstant[16] = <BurnFactor>;
PixelShaderConstant[17] = <Ambient>;
PixelShader =
asm
{
ps_1_4
def c0, 1, 1, 1, 1
def c1, 0.0, 0.0, 0.0, 0
def c2, 0., 0., 0., .0 // zero
def c3, 1.0, 1.0, 1.0, 1.0 // fog color
def c18, 10., 0., 0.1, 1.0 // ambient color
dcl t0.xy
dcl t1.xy
dcl t2.xy
dcl t3.x
dcl t4.xy
dcl v0.rgba
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
texld r10, t1, s1 // Z - semplovani Z projektovane teksture
sub r9.r, r10.r, t3.x // razlika Z vrednosti
mov r1, c1 // r1 - 1, 1, 1, 1
cmp r10, r9.r, c0, r1 //-r9.r//, r1
texld r1, t0, s0
mad r0, r10, v0, c17 // (shadow * diffuse) + ambient
texld r2, t4, s3 // r2 = burn texture
lrp r3, r2.a, r1, r2
lrp r2, c16.x, r1, r3
mul r0, r2, r0
texld r2, t2, s2
mul r0, r2, r0
// add_sat r0, r0, c15
mov r0.a, r1.a
mov oC0, r0 // output
};
}
}
// rendering u shadow mapu
technique Technique5
{
pass Pass0
{
Texture[0] = (DiffuseTexture);
VertexShaderConstant[0] = <WorldViewProjection>;
VertexShaderConstant[31] = <ZBias>;
ALPHABLENDENABLE = TRUE;
SRCBLEND = SRCALPHA;
DESTBLEND = INVSRCALPHA;
ALPHATESTENABLE = TRUE;
ALPHAFUNC = GREATER;
ALPHAREF = 1;
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v6[2]; // Texture coord1
}
asm
{
//-----------------------------------------------------------------------------
// Vertex shader for rendering shadows
// c0..3 - WVP
// c4..7 - world to light proj x-form
// c8..11 - shadow proj x-form
// c12.13 - View matrix
// c30 - light direction
// c31 - Z Bias vector
//-----------------------------------------------------------------------------
vs_1_1
dcl_position v0
dcl_texcoord0 v6
m4x4 r0, v0, c0 // Transform position
mov oPos, r0 // Output position
mov oT0, v6
mov oT1.x, r0.z // Output depth
};
PixelShader =
asm
{
ps_1_4
// Incoming depth
dcl t0.xyzw
dcl t1.x
dcl_2d s0
texld r1, t0, s0
mov r0, t1.x
mov r0.w, r1.w
mov oC0, r0
};
}
}